有关smarty缓存的应用
$cache_id=null, $tpl_file=null。
$compile_id=null){ } 该函数的一般是根椐$action来判断缓存当前操作: 复制代码 代码示例: switch($action){ case read://读取缓存内容 case write://写入缓存 case clear://清空 } 一般使用md5($tpl_file.$cache_id.$compile_id)作为唯一的cache_id 如果需要。
$smarty) { return $content; } ? 2) 编写程序及模板 示例程序:testCacheLess.php 复制代码 代码如下: ?php include('Smarty.class.php'); $smarty = new Smarty; $smarty-caching=true; $smarty-cache_lifetime = 6; $smarty-display('cache.tpl'); ? 所用的模板:cache.tpl 已经缓存的:{$smarty.now}br {cacheless} 没有缓存的:{$smarty.now} {/cacheless} 四、自定义缓存 设置cache_handler_func使用自定义的函数处理缓存 如: 复制代码 代码示例: $smarty-cache_handler_func = myCache; function myCache($action, 复制代码 代码如下: {insert name=get_time} 第二个: smarty_block 定义一个block:smarty_block_name($params,为false的时候缓存无效 $smarty-cache_lifetime=60; //缓存时间,单位是秒 二、Smarty缓存的使用与清除 复制代码 代码如下: $marty-display(cache.tpl,cache_id); //清楚index.php中指定ID的缓存 三、Smarty的局部缓存 第一个: insert_函数默认是不缓存, false); //第三参数false表示该区域不被缓存 模板写法:{name}内容{/name} 写成block插件: 1)定义一件插件函数:block.cacheless.php, 一、Smarty缓存的配置: 复制代码 代码如下: $smarty-cache-dir=目录名; //创建缓存目录名 $smarty-caching=true; //开启缓存, 复制代码 代码如下: function insert_get_time(){ return date(Y-m-d H:m:s); } index.html中,可使用gzcompress和gzuncompress来压缩和解压,放在smarty的plugins目录 block.cacheless.php的内容如下: 复制代码 代码如下: ?php function smarty_block_cacheless($param, $content, $smarty_obj, , 'smarty_block_name',$content,这个属性是不能修改 使用方法:例子 index.php中。
$cache_content。
$smarty){return $content;} //name表示区域名 注册block:$smarty-register_block('name',cache_id); //创建带ID的缓存 $marty-clear_all_cache(); //清楚所有缓存 $marty-clear_cache(index.php); //清楚index.php中的缓存 $marty-clear_cache(index.php',。
相关热词:
本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!
本文地址: https://v30.fanwenzhu.com/jq/jc/9502.shtml
相关文章
热门TAG
win10 ecshop 主机 阿里云 解决 配置 C# C++ 解析 SQL语句 命令 Go语言 方法 CSS3 HTML5 CSS win7 MSSQL 服务器配置 IIS7.5 IIS7 IIS6 IIS CentOS 7 Linux oracle数据库 oracle phpcms discuz discuz教程最新文章
-
PHP识别相片是否是颠倒的
时间:2020-12-28
-
python编程有哪些ide
时间:2020-12-28
-
python开发工程师是做什么
时间:2020-12-28
-
php构造函数的作用
时间:2020-12-28
-
php怎么跟数据库连接
时间:2020-12-28
-
php实现顺序线性表
时间:2020-12-28
-
Python多重继承中的菱形继
时间:2020-12-28
-
php中break的作用
时间:2020-12-28
热门文章
-
php中常用的正则表达式使用方法
时间:2020-12-25
-
asp与php区别是什么?
时间:2020-12-27
-
PHP识别相片是否是颠倒的,并且重新摆正
时间:2020-12-28
-
Yii授权之基于角色的存取控制 (RBAC)
时间:2020-12-23
-
php的一键安装包有哪些 php环境搭建
时间:2020-12-19
-
php实现对图片对称加解密(适用身份证加
时间:2020-12-25
-
php如何理解面向对象
时间:2020-12-28
-
超详细分析php docker的原理及作用
时间:2020-12-27
-
Python控制Excel实现自动化办公
时间:2020-12-23
-
session的作用是什么
时间:2020-12-25
